<%@include file="init.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<div class="container-left">
	<%
		int categoryId = -1;

		if (request.getParameter("categoryId") != null)
			categoryId = Integer
					.valueOf(request.getParameter("categoryId"));
		List<Category> categorys = null;
		List<Category> rootCategorys = dataManager
				.getCategorysByParentId(0);
		int categoryParentId = -1;

		if (categoryId != -1) {
			categorys = dataManager.getCategorysByParentId(categoryId);
			categoryParentId = categoryId;
			if (categorys.isEmpty()) {
				categoryParentId = dataManager.getCategoryWithCategoryId(
						categoryId).getCategoryParentId();
				categorys = dataManager
						.getCategorysByParentId(categoryParentId);
			}
		}
	%>
	<div class="ml-banner">
		<div class="ml-title">Nhóm sản phẩm</div>
	</div>
	<div class="ml-content">
		<%
			for (Category rootCategory : rootCategorys) {
		%>
		<div class="ml-muclon">
			<a class="linklon"
				href=<%="default.jsp?categoryId="
						+ rootCategory.getCategoryId()%>><%=rootCategory.getCategoryName().replace(" ", "&nbsp")%></a>
			<br>
		</div>
		<%
				if (categoryParentId != -1
						&& categoryParentId == rootCategory.getCategoryId()) {
					for (Category category : categorys) {
		%>
		<div class="ml-mucnho">
			<a class="linknho"
				href=<%="default.jsp?categoryId="
								+ category.getCategoryId()%>><%=category.getCategoryName().replace(" ",
								"&nbsp")%></a>
			<br>
		</div>
		<%
			}
				}
			}
		%>
	</div>
</div>